﻿#include"stdafx.h"
#include"QQGroupZYZ.h"
#include"accountStateZYZ.h"
#include"accountZYZ.h"
#include"serviceZYZ.h"
#include"WeChatServiceZYZ.h"
#include"QQServiceZYZ.h"
#include"WeBlogServiceZYZ.h"

#include"QQMasterAccount.h"
void init();
void recoverLog();

void setCurrGroup(chatGroupZYZ* group);

extern accountZYZ currAccount;
extern std::vector<serviceZYZ*> services;
extern chatGroupZYZ* currGroup;

std::string QQGroupZYZ::serviceName = "QQ";
std::string WeChatGroupZYZ::serviceName = "WeChat";

int main()
{
    services.push_back(new QQServiceZYZ());//装载服务实例
    services.push_back(new WeChatServiceZYZ());
    services.push_back(new WeBlogServiceZYZ());
    std::string name[] = { "QQ", "微信","微博","退出"};
    int opt = 0;
    int optNum = 4;
    while (opt < optNum)
    {
        system("cls");
        std::cout << "选择服务APP：" << std::endl;
        for (int i = 0; i < optNum; i++)
        {
            printf("%d.%s\n", i + 1, name[i].c_str());
        }
        int opt = getOpt(optNum);
        if (opt == optNum-1)
            break;
        services[opt]->UI();
    }
    currAccount.write2File();
    if(currGroup!=nullptr)
        currGroup->write2File();
    printf("已保存数据并退出");
}

void test1()
{
    std::set<int>mem;
    mem.insert(15701);
    mem.insert(2333);
    WeChatGroupZYZ testGroup = WeChatGroupZYZ(1001, "test", 15701, mem);
    testGroup.write2File();
    auto ins = WeChatGroupZYZ::getGroup(1001);
    std::cout << ins->groupName;
    //int (*p[1])(void) = { accountZYZ::getAccount() };
    std::string s[1] = { "UI" };
    //panelUI("test", p, s, 1);
}
void test2()
{
    int id = 10000;
    std::string name = "Zoar";
    time_t ctime = time(0);
    std::string location = "erciyuan";
    std::map<std::string, std::vector<int> > friendList;
    std::map<std::string, int> semiIDs;
    std::map<std::string, std::vector<int> > groups;

    std::vector<int> ids;
    ids.push_back(10011);
    ids.push_back(10063);
    friendList["QQ"] = ids;

    ids.clear();
    ids.push_back(20029);
    ids.push_back(11111);
    ids.push_back(10039);
    friendList["WeChat"] = ids;
    semiIDs["Wechat"] = 1571053;

    ids.clear();
    ids.push_back(2002);
    ids.push_back(1111);
    ids.push_back(1003);
    groups["QQ"] = ids;

    ids.clear();
    ids.push_back(1111);
    ids.push_back(2002);
    groups["WeChat"] = ids;

    semiIDs["WeChat"] = 4227;
}
